home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / an210x / bindery.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  12.5 KB  |  347 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Bindery Object Lister"
  5.    ClientHeight    =   4725
  6.    ClientLeft      =   135
  7.    ClientTop       =   600
  8.    ClientWidth     =   9510
  9.    Height          =   5130
  10.    Icon            =   BINDERY.FRX:0000
  11.    Left            =   75
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   4725
  15.    ScaleWidth      =   9510
  16.    Top             =   255
  17.    Width           =   9630
  18.    Begin CommandButton CloseButton 
  19.       Caption         =   "Close"
  20.       Height          =   375
  21.       Left            =   7800
  22.       TabIndex        =   0
  23.       Top             =   4200
  24.       Width           =   1335
  25.    End
  26.    Begin CommandButton AboutButton 
  27.       Caption         =   "About ..."
  28.       Height          =   375
  29.       Left            =   6000
  30.       TabIndex        =   2
  31.       Top             =   3960
  32.       Width           =   1335
  33.    End
  34.    Begin CommandButton RescanButton 
  35.       Caption         =   "Rescan"
  36.       Height          =   375
  37.       Left            =   7800
  38.       TabIndex        =   16
  39.       Top             =   3720
  40.       Width           =   1335
  41.    End
  42.    Begin ListBox ServerNameBox 
  43.       Height          =   810
  44.       Left            =   1440
  45.       TabIndex        =   15
  46.       Top             =   3720
  47.       Width           =   3855
  48.    End
  49.    Begin ListBox BinderyObjList 
  50.       FontBold        =   -1  'True
  51.       FontItalic      =   0   'False
  52.       FontName        =   "Courier"
  53.       FontSize        =   9.75
  54.       FontStrikethru  =   0   'False
  55.       FontUnderline   =   0   'False
  56.       Height          =   2565
  57.       Left            =   45
  58.       Sorted          =   -1  'True
  59.       TabIndex        =   1
  60.       Top             =   945
  61.       Width           =   9420
  62.    End
  63.    Begin Label Label10 
  64.       Caption         =   "File Server:"
  65.       Height          =   255
  66.       Left            =   360
  67.       TabIndex        =   11
  68.       Top             =   3720
  69.       Width           =   1095
  70.    End
  71.    Begin Label Label1 
  72.       Caption         =   "Add Props"
  73.       Height          =   255
  74.       Left            =   8400
  75.       TabIndex        =   9
  76.       Top             =   600
  77.       Width           =   975
  78.    End
  79.    Begin Label Label7 
  80.       Caption         =   "Scan"
  81.       Height          =   255
  82.       Left            =   7800
  83.       TabIndex        =   8
  84.       Top             =   600
  85.       Width           =   495
  86.    End
  87.    Begin Label Label14 
  88.       BorderStyle     =   1  'Fixed Single
  89.       Caption         =   "Label14"
  90.       Height          =   15
  91.       Left            =   7800
  92.       TabIndex        =   12
  93.       Top             =   480
  94.       Width           =   1455
  95.    End
  96.    Begin Label Label4 
  97.       Caption         =   "Object ID"
  98.       Height          =   255
  99.       Left            =   5280
  100.       TabIndex        =   5
  101.       Top             =   480
  102.       Width           =   855
  103.    End
  104.    Begin Label Label3 
  105.       Caption         =   "Object Type"
  106.       Height          =   255
  107.       Left            =   3120
  108.       TabIndex        =   4
  109.       Top             =   480
  110.       Width           =   1095
  111.    End
  112.    Begin Label Label2 
  113.       Caption         =   "Object Name"
  114.       Height          =   255
  115.       Left            =   120
  116.       TabIndex        =   3
  117.       Top             =   480
  118.       Width           =   1215
  119.    End
  120.    Begin Label Label6 
  121.       Alignment       =   2  'Center
  122.       Caption         =   "Dyn/ Stat"
  123.       Height          =   375
  124.       Left            =   7035
  125.       TabIndex        =   7
  126.       Top             =   360
  127.       Width           =   615
  128.    End
  129.    Begin Label Label5 
  130.       Alignment       =   2  'Center
  131.       Caption         =   "Has Props"
  132.       Height          =   375
  133.       Left            =   6360
  134.       TabIndex        =   6
  135.       Top             =   360
  136.       Width           =   615
  137.    End
  138.    Begin Label Label8 
  139.       Caption         =   "Access Control"
  140.       Height          =   255
  141.       Left            =   7875
  142.       TabIndex        =   10
  143.       Top             =   225
  144.       Width           =   1335
  145.    End
  146.    Begin Label Label9 
  147.       BorderStyle     =   1  'Fixed Single
  148.       Caption         =   "Label9"
  149.       Height          =   855
  150.       Left            =   9450
  151.       TabIndex        =   13
  152.       Top             =   90
  153.       Width           =   15
  154.    End
  155.    Begin Label Label15 
  156.       BorderStyle     =   1  'Fixed Single
  157.       Caption         =   "Label15"
  158.       Height          =   15
  159.       Left            =   45
  160.       TabIndex        =   14
  161.       Top             =   90
  162.       Width           =   9420
  163.    End
  164.    Begin Label Label11 
  165.       BorderStyle     =   1  'Fixed Single
  166.       Height          =   915
  167.       Left            =   45
  168.       TabIndex        =   17
  169.       Top             =   90
  170.       Width           =   15
  171.    End
  172. Sub AboutButton_Click ()
  173.     Form2.Show 1
  174. End Sub
  175. Function CheckDLLVersions (DLLName$, expMajVer%, expMinVer%, expRev%, expBeta%) As Integer
  176.     CrLf$ = Chr$(13) + Chr$(10)
  177.     ccode% = GetDLLVersion(DLLName$, majorVer%, minorVer%, revLevel%, betaLevel%)
  178.     If ((majorVer% < expMajVer%) Or ((majorVer% = expMajVer%) And (minorVer% < expMinVer%)) Or ((majorVer% = expMajVer%) And (minorVer% = expMinVer%) And (revLevel% < expRev%))) Then
  179.         'ignore beta level
  180.         Msg$ = "Incorrect version of " + DLLName$ + CrLf$
  181.         Msg$ = Msg$ + "Your version is: " + Str$(majorVer%) + "." + Format$(minorVer%, "#")
  182.         Msg$ = Msg$ + Format$(revLevel%, "#") + Format$(betaLevel%, "#") + CrLf$
  183.         Msg$ = Msg$ + "This program requires " + Str$(expMajVer%) + "." + Format$(expMinVer%, "#") + Format$(expRev%, "#") + " or above"
  184.         MsgBox Msg$, 16, "Critical Error"
  185.         CheckDLLVersions = False
  186.     Else
  187.         CheckDLLVersions = True
  188.     End If
  189. End Function
  190. Sub CloseButton_Click ()
  191.     End
  192. End Sub
  193. Sub Form_Load ()
  194.     Screen.MousePointer = 11        'change mouse cursor to hourglass
  195.     'make sure we're using right versions of NetWare DLLs
  196.     If (Not CheckDLLVersions("NWCore.DLL", 1, 2, 2, 0)) Then
  197.         End
  198.     End If
  199.     If (Not CheckDLLVersions("NWWrkstn.DLL", 1, 2, 2, 0)) Then
  200.         End
  201.     End If
  202.     If (Not CheckDLLVersions("NWServer.DLL", 1, 2, 2, 0)) Then
  203.         End
  204.     End If
  205.     If (Not CheckDLLVersions("NWBind.DLL", 1, 2, 2, 0)) Then
  206.         End
  207.     End If
  208.     For connID& = 1 To 8
  209.         'for each connection in workstation's file server name table
  210.         'get the table entry, then see if it's null
  211.         
  212.         fileServerName$ = String$(48, 0)
  213.         GetFileServerName connID&, fileServerName$
  214.         If Left$(fileServerName$, 1) <> Chr$(0) Then
  215.             'you have to explicitly look for a null in the first character,
  216.             'because Visual Basic doesn't know about null-terminated strings
  217.             '(a null prints as a space)
  218.             
  219.             ServerNameBox.AddItem fileServerName$
  220.         End If
  221.     Next connID&
  222.     ScanBindery     'scan the bindery of the default server
  223. End Sub
  224. Sub RescanButton_Click ()
  225.     ServerNameBox_DblClick  'same effect as if the user had
  226.                             'double-clicked on a file server name
  227. End Sub
  228. Sub ScanBindery ()
  229.     Dim objectType As String * 6
  230.     Screen.MousePointer = 11        'change mouse cursor to hourglass
  231.     Do While BinderyObjList.ListCount
  232.         'clear out the old list of bindery objects
  233.         BinderyObjList.RemoveItem 0
  234.     Loop
  235.     oID& = -1   'initialize object ID to -1 for first call to ScanBinderyObject
  236.     Do
  237.         oName$ = String$(48, 0)
  238.         ccode% = ScanBinderyObject("*", OT_WILD, oID&, oName$, oType%, oHasProps%, oFlag%, oSecurity%)
  239.         If (Not ccode%) Then
  240.             'take all characters of object name up to terminating null
  241.             out$ = Left$(oName$, InStr(oName$, Chr$(0)) - 1)
  242.             'then take first 20 chars
  243.             out$ = Left$(out$, 20)
  244.             'pad with spaces
  245.             out$ = out$ + Space$(22 - Len(out$))
  246.             
  247.             Select Case oType%
  248.                 Case OT_USER
  249.                     out$ = out$ + "User            "
  250.                 Case OT_USER_GROUP
  251.                     out$ = out$ + "User Group      "
  252.                 Case OT_PRINT_QUEUE
  253.                     out$ = out$ + "Print Queue     "
  254.                 Case OT_FILE_SERVER
  255.                     out$ = out$ + "File Server     "
  256.                 Case OT_JOB_SERVER
  257.                     out$ = out$ + "Job Server      "
  258.                 Case OT_GATEWAY
  259.                     out$ = out$ + "Gateway         "
  260.                 Case OT_PRINT_SERVER
  261.                     out$ = out$ + "Print Server    "
  262.                 Case OT_ARCHIVE_QUEUE
  263.                     out$ = out$ + "Archive Queue   "
  264.                 Case OT_ARCHIVE_SERVER
  265.                     out$ = out$ + "Archive Server  "
  266.                 Case OT_JOB_QUEUE
  267.                     out$ = out$ + "Job Queue       "
  268.                 Case OT_ADMINISTRATION
  269.                     out$ = out$ + "Administration  "
  270.                 Case OT_NAS_SNA_GATEWAY
  271.                     out$ = out$ + "NAS SNA Gateway "
  272.                 Case OT_REMOTE_BRIDGE_SERVER
  273.                     out$ = out$ + "Rem Bridge Serv "
  274.                 Case OT_TIME_SYNCHRONIZATION_SERVER
  275.                     out$ = out$ + "Time Synch Serv "
  276.                 Case OT_ARCHIVE_SERVER_DYNAMIC_SAP
  277.                     out$ = out$ + "Arch Srv DynSAP "
  278.                 Case OT_ADVERTISING_PRINT_SERVER
  279.                     out$ = out$ + "Adver Print Srv "
  280.                 Case OT_BTRIEVE_VAP
  281.                     out$ = out$ + "Btrieve VAP     "
  282.                 Case OT_PRINT_QUEUE_USER
  283.                     out$ = out$ + "Print Q User    "
  284.                 Case Else
  285.                     objectType = Str$(oType%)
  286.                     out$ = out$ + "[" + objectType + "]" + "        "
  287.             End Select
  288.             'format the bindery object ID as 8 hex digits, with leading zeros
  289.             out$ = out$ + String$((8 - Len(Hex$(oID&))), "0") + Hex$(oID&) + "  "
  290.             'does the bindery object have properties?
  291.             If oHasProps% = 0 Then
  292.                 out$ = out$ + "N   "
  293.             Else
  294.                 out$ = out$ + "Y   "
  295.             End If
  296.             'is the bindery object static or dynamic?
  297.             If oFlag% = 0 Then
  298.                 out$ = out$ + "Stat  "
  299.             Else
  300.                 out$ = out$ + "Dyn   "
  301.             End If
  302.             'who can scan for the bindery object,
  303.             'and who can add properties?
  304.             Select Case (oSecurity% And &HF)
  305.                 Case &H0
  306.                     out$ = out$ + "Any  "   'anyone can scan for the object
  307.                 Case &H1
  308.                     out$ = out$ + "Log  "   'any logged user can scan
  309.                 Case &H2
  310.                     out$ = out$ + "Obj  "   'only the object can scan for itself
  311.                 Case &H3
  312.                     out$ = out$ + "Sup  "   'only the supervisor can scan
  313.                 Case &H4
  314.                     out$ = out$ + "OS   "   'only the operating system can scan
  315.             End Select
  316.             
  317.             Select Case (oSecurity% And &HF0)
  318.                 Case &H0
  319.                     out$ = out$ + "Any  "   'anyone can add properties to the object
  320.                 Case &H10
  321.                     out$ = out$ + "Log  "   'any logged user can add properties
  322.                 Case &H20
  323.                     out$ = out$ + "Obj  "   'only the object can add props to itself
  324.                 Case &H30
  325.                     out$ = out$ + "Sup  "   'only the supervisor can add props
  326.                 Case &H40
  327.                     out$ = out$ + "OS   "   'only the OS can add properties
  328.             End Select
  329.             
  330.             'finally, add one more entry to the list
  331.             'of bindery objects
  332.             BinderyObjList.AddItem out$
  333.         End If
  334.     Loop Until ccode%
  335.     Screen.MousePointer = 0     'change mouse cursor back to how it was
  336. End Sub
  337. Sub ServerNameBox_DblClick ()
  338.     prefServer$ = ServerNameBox.Text
  339.     ccode% = GetConnectionID(prefServer$, connID%)
  340.     'a better program would check the ccode here, to see
  341.     'if the connID is valid (maybe the user has disconnected
  342.     'from the specified file server after running this program)
  343.     SetPreferredConnectionID (connID%)  'tell which file server to send
  344.                                         '   requests to
  345.     ScanBindery                         'then go scan its bindery
  346. End Sub
  347.